package com.example.medicine.View;

import com.example.medicine.Bean.book;
import com.example.medicine.Mapper.bookMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
@Slf4j
@Controller
public class BookView {
    private static final String UPLOADED_FOLDER = System.getProperty("user.dir") +
            "/src/main/resources/static/uploadImages/";
    @Autowired
    private bookMapper bookMapper;
    /**
     * 展示书籍列表
     * @return
     */
    @RequiresPermissions("书籍管理")
    @RequestMapping("/book")
    public String bookShow(){
        log.info("书籍列表页面");
        return "pages/Book/list";
    }
    @RequiresPermissions("书籍管理")
    @RequestMapping("/book/create")
    public String bookCreateShow(){
        log.info("书籍创建页面");
        return "pages/Book/create";
    }

    @RequiresPermissions("书籍管理")
    @RequestMapping("/book/edit/{id}")
    public String getMyxxById(@PathVariable String id, Model model) throws IOException {
        log.info("书籍编辑页面");
        book book=bookMapper.getById(id);
        book.setId(id);
        model.addAttribute("book",book);
        return "pages/Book/edit";
    }

    @RequiresPermissions("书籍管理")
    @RequestMapping("/book/batchAdd")
    public String batchAddShow(){
        log.info("书籍批量导入页面");
        return "pages/Book/batchAdd";
    }
}

